//
//  SignleCateoryView.m
//  DogeLegs
//
//  Created by 宋华 on 2017/9/9.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "SignleCateoryView.h"

@interface SignleCateoryView () {

}

@property (strong, nonatomic)  UIImageView *cateoryImageview;

@property (strong, nonatomic)  UILabel *cateoryLabel;

@property (strong,nonatomic) UIImageView *rightArrowImageview;

@property (nonatomic,strong)UIView *lineview;

@end

@implementation SignleCateoryView


- (instancetype)init {
    if (self = [super init]) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    [self addSubview:self.cateoryImageview];
    [self addSubview:self.cateoryLabel];
    [self addSubview:self.lineview];
    [self addSubview:self.rightArrowImageview];
    WeakSelf(ws);
    [self.cateoryImageview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.mas_left).offset(15);
        make.right.mas_equalTo(ws.cateoryLabel.mas_left).offset(-5);
        make.centerY.mas_equalTo(ws.mas_centerY);
        make.width.mas_equalTo(12);
        make.height.mas_equalTo(12);
    }];
    
    [self.cateoryLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws.mas_centerY);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(17);
    }];
    
    [self.rightArrowImageview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(ws.mas_centerY);
        make.right.mas_equalTo(ws.mas_right).offset(-15);
        make.width.mas_equalTo(5);
        make.height.mas_equalTo(8);
    }];
    [self.lineview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.mas_left).offset(15);
        make.right.mas_equalTo(ws.mas_right).offset(-15);
        make.bottom.mas_equalTo(ws.mas_bottom).offset(0);
        make.height.mas_equalTo(0.5);
    }];
    
}


#pragma mark - getter
- (UIImageView *)cateoryImageview {
    if (_cateoryImageview == nil) {
        _cateoryImageview = [[UIImageView alloc] init];
        _cateoryImageview.image = [UIImage imageNamed:@"photo"];
    }
    return _cateoryImageview;
}

- (UILabel *)cateoryLabel {
    if (_cateoryLabel == nil) {
        _cateoryLabel = [[UILabel alloc] init];
        _cateoryLabel.textColor = HEXCOLOR(0x333333);
        _cateoryLabel.font = [UIFont systemFontOfSize:14];
//        _cateoryLabel.userInteractionEnabled = YES;
    }
    return _cateoryLabel;
}

- (UIImageView *)rightArrowImageview {
    if (_rightArrowImageview == nil) {
        _rightArrowImageview = [[UIImageView alloc] init];
        _rightArrowImageview.image = [UIImage imageNamed:@"right_arrow"];
    }
    return _rightArrowImageview;
}

- (UIView *)lineview {
    if (_lineview == nil) {
        _lineview = [[UIView alloc] init];
        _lineview.backgroundColor = HEXCOLOR(0xCFCED3);
    }
    return _lineview;
}

#pragma mark - public

- (void)cellWillDisplay:(PostCellType)type labelText:(NSString *)text {
    if (type == PostCellType_location) {
        self.cateoryImageview.image = [UIImage imageNamed:@"photo"];
        self.rightArrowImageview.hidden = YES;
    } else {
        self.cateoryImageview.image = [UIImage imageNamed:@"photo"];
        self.lineview.hidden = YES;
    }
    self.cateoryLabel.text = text;

    
}


@end
